<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>get()方法</title>
</head>
<style>
   /*ul li {*/
   /*     list-style: none;*/
   /*     display: inline;*/
   /*     padding: 15px;*/

   /* }*/
</style>
<body>
<!--直接拿值-->
<div id="app">
    <ul>
    <li v-for="(item,index) in comments" :key="index">
                    {{item.commentTxt}}&nbsp;&nbsp;&nbsp;&nbsp;{{item.createAt}}
    </li>
    </ul>
    <button @click='post'>post方法</button>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            comments: []
        },
        // 钩子函数
        methods: {
            post() {
                axios.post('comment.json', {}).then(
                    response => {
                        this.comments = response.data.data.commentList
                    }).catch(
                    err => {
                        console.log(err);
                    });

            }
        }

    });
</script>
</body>
</html>

